package com.harboursoftware.xstorage;

import org.jets3t.service.Jets3tProperties 
import org.jets3t.service.S3Service;
import org.jets3t.service.impl.rest.httpclient.RestS3Service 
import org.jets3t.service.security.AWSCredentials 

class Test {

    static main(args) {

        //crateS3PostFrom()
        createBucket();
    }

    static void crateS3PostFrom() {
        def awsAccessKey = '0PN5J17HBGZHT7JJ3X82'
        def awsSecretAccessKey = 'uV3F3YluFJax1cknvbcGwgjvx4QpvB+leU8dUj2o'
        Jets3tProperties props = new Jets3tProperties();
        props.setProperty("s3service.https-only", 'false')
        props.setProperty('s3service.internal-error-retry-max', '0')
        AWSCredentials credentials = new AWSCredentials(awsAccessKey, awsSecretAccessKey);
        def s3Service = new RestS3Service(credentials, 'x-storage-test', null, props);
        def postForm = S3Service.buildPostForm("harboursoftware", "test", credentials, new Date(), new String[0], new String[0], "", false)
        println postForm
    }
    
    static void createBucket() {
        def awsAccessKey = '0PN5J17HBGZHT7JJ3X82'
        def awsSecretAccessKey = 'uV3F3YluFJax1cknvbcGwgjvx4QpvB+leU8dUj2o'
        Jets3tProperties props = new Jets3tProperties();
        props.setProperty("s3service.https-only", 'false')
        props.setProperty('s3service.internal-error-retry-max', '0')
        AWSCredentials credentials = new AWSCredentials(awsAccessKey, awsSecretAccessKey);
        def s3Service = new RestS3Service(credentials, 'x-storage-test', null, props);
        s3Service.createBucket 'harboursoftware'
    }
}
